<?php


namespace app\common\model;


use think\Model;

class BaseModel extends Model
{
    protected $autoWriteTimestamp = true;
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';
    protected $dateFormat = "Y-m-d";
    protected $type = [
        "start_time" => "timestamp",
        "end_time" => "timestamp"
    ];

    public function __construct(array $data = [])
    {
        parent::__construct($data);
    }

    public function setUpdateTimeAttr($value)
    {
        return is_integer($value) ? $value : strtotime($value);
    }

    public function setCreateTimeAttr($value)
    {
        return is_integer($value) ? $value : strtotime($value);
    }

    public static function all($where = [])
    {
        return self::where($where)->order('id desc')->select();
    }
    
    public static function getList($page = 1, $filed='*',$where = [],$limit = 10) {
        return self::where($where)->order('id desc')
            ->field($filed)
            ->paginate(['list_rows' => $limit, 'page' => $page]);
    }
}